package aop.cglib;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class Main {
	
	public static void main(String[] args) {
		
		TargetClass target=new TargetClass();
		Invocation invocation=new Invocation(target);
		target.save();
		
	}

}

class Invocation implements InvocationHandler
{
	private Object target;
	public Invocation(Object target)
	{
		this.target=target;
	}
	public Object invoke(Object obj, Method method, Object[] arg2) throws Throwable {
		if(obj instanceof TargetClass) {
//			Target target = (Target) obj;
			System.out.println("---------proxy instanceof Target----------");
		}
		System.out.println(obj);
		return method.invoke(target, arg2);
	}
	
}
